﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using System.Xml.Linq;
using System.Text.RegularExpressions;

namespace _110ConsultingMVC.Controllers
{
    public class CareersController : Controller
    {
        //
        // GET: /Careers/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult culture_benefits()
        {
            return View("culture_benefits");
        }

        public ActionResult jobs()
        {
            XDocument feedXML = XDocument.Load(@"http://www.maxhire.net/cp/(A(DRtKWznfzQEkAAAAOWNhNTgwZTItNGYwMi00OWY4LWExMjUtYjE1ZTA1M2VmNGM3jd5TjbRW67rlub9igyoRUX6iSsg1)S(iw5a5n450vblgb55vpvwq555))/rssCurrentJobs.aspx?site=5F6D361D43515B7D561C2B&L=EN");
            XNamespace nsContent = "http://purl.org/rss/1.0/modules/content/";
            //select out a collection of anonymous types from RSS feed       
            var feedCollection = from rss in feedXML.Descendants("item")
                                 select new _110ConsultingMVC.Models.Feed
                                 {
                                     Title = rss.Element("title").Value,
                                     Link = rss.Element("link").Value,
                                     Description = rss.Element("description").Value,
                                     Content = rss.Element("description").Value,
                                     Category = rss.Element("category").Value,
                                     Date = rss.Element("pubDate").Value,
                                     ID = rss.Element("guid").Value
                                 };
            //XDocument feedXML = XDocument.Load("http://110consulting.wordpress.com/category/job-opening/feed/");
            //XNamespace nsContent = "http://purl.org/rss/1.0/modules/content/";  
            ////select out a collection of anonymous types from RSS feed       
            //var feedCollection = from rss in feedXML.Descendants("item")
            //                     select new _110ConsultingMVC.Models.Feed
            //                     {
            //                         Title = rss.Element("title").Value,
            //                         Link = rss.Element("link").Value,
            //                         Description = rss.Element("description").Value,
            //                         Content = rss.Element(nsContent + "encoded").Value,
            //                         Category = rss.Element("category").Value,
            //                         Date = rss.Element("pubDate").Value,
            //                         ID = rss.Element("guid").Value
            //                     };
            return View("jobs", feedCollection);
        }

        public ActionResult job_detail()
        {
            XDocument feedXML = XDocument.Load(@"http://www.maxhire.net/cp/(A(DRtKWznfzQEkAAAAOWNhNTgwZTItNGYwMi00OWY4LWExMjUtYjE1ZTA1M2VmNGM3jd5TjbRW67rlub9igyoRUX6iSsg1)S(iw5a5n450vblgb55vpvwq555))/rssCurrentJobs.aspx?site=5F6D361D43515B7D561C2B&L=EN");
            XNamespace nsContent = "http://purl.org/rss/1.0/modules/content/";
            //select out a collection of anonymous types from RSS feed       
            var feedCollection = from rss in feedXML.Descendants("item")
                                 select new _110ConsultingMVC.Models.Feed
                                 {
                                     Title = rss.Element("title").Value,
                                     Link = rss.Element("link").Value,
                                     // change description.
                                     Description = rss.Element("description").Value,
                                     Content = rss.Element("description").Value,
                                     Category = rss.Element("category").Value,
                                     Date = rss.Element("pubDate").Value,
                                     ID = rss.Element("guid").Value
                                 };
            //XDocument feedXML = XDocument.Load("http://110consulting.wordpress.com/category/job-opening/feed/");
            //XNamespace nsContent = "http://purl.org/rss/1.0/modules/content/";
            ////select out a collection of anonymous types from RSS feed       
            //var feedCollection = from rss in feedXML.Descendants("item")
            //                     select new _110ConsultingMVC.Models.Feed
            //                     {
            //                         Title = rss.Element("title").Value,
            //                         Link = rss.Element("link").Value,
            //                         Description = rss.Element("description").Value,
            //                         Content = rss.Element(nsContent + "encoded").Value,
            //                         Category = rss.Element("category").Value,
            //                         Date = rss.Element("pubDate").Value,
            //                         ID = rss.Element("guid").Value
            //                     };
            return View("job_detail", feedCollection);
        }

    }
}
